<template>

    <el-drawer v-model="visible" title="设置"  :size="480" append-to-body>
        <Vue3Cron v-model="expression" :locale="locale"/>
        <template #footer>
            <el-button @click="visible = false">取消</el-button>
            <el-button type="primary" @click="renderCronExpression()">确定</el-button>
        </template>
    </el-drawer>
</template>

<script lang="ts" setup>
    import {ref} from "vue";
    import Vue3Cron from '@/components/vue3-cron';

    const emit = defineEmits(['renderCronExpression'])

    const expression = ref('1 * * * * ?')
    const locale = ref('cn')

    const visible = ref(false)
    const init = (exp?: string) => {
        visible.value = true
        if(exp){
        	expression.value=exp
        }
    }

    const renderCronExpression =()=>{
        emit('renderCronExpression',expression.value)
        visible.value = false
    }
    defineExpose({
        init
    })
</script>
